package com.bite.demo;

import ch.qos.logback.classic.spi.EventArgUtil;
import com.bite.demo.component.UserComponent;
import com.bite.demo.config.UserConfig;
import com.bite.demo.controller.UserController;
import com.bite.demo.model.UserInfo;
import com.bite.demo.repository.UserRepository;
import com.bite.demo.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class SpringIocApplication {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(SpringIocApplication.class, args);
		UserController bean1 = context.getBean(UserController.class);
		//System.out.println(bean1);
		bean1.sayHi();

/*//根据类型
		UserService userService = context.getBean(UserService.class);
		System.out.println(userService1);
		//根据名称
		UserService userService2 = (UserService) context.getBean("userService");
		System.out.println(userService2);
		//根据类型和名称
		UserService userService3 = context.getBean(UserService.class, "userService");
		System.out.println(userService3);
*/
		/*UserRepository userRepository = context.getBean(UserRepository.class);
		userRepository.sayHi();

		UserComponent userComponent = context.getBean(UserComponent.class);
		userComponent.sayHi();

		UserConfig userConfig = context.getBean(UserConfig.class);
		userConfig.sayHi();*/
/*
		UserInfo userInfo = context.getBean("u1",UserInfo.class);
		System.out.println(userInfo);
		UserInfo userInfo2 = context.getBean("u2",UserInfo.class);
		System.out.println(userInfo2);*/


	}

}
